import { baseFileds } from "../options";
import { mapState, mapActions } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapState("options", ["personList"]),
    fileds() {
      return baseFileds(
        this.type === "detail" ? "detail" : "add",
        this.formData.startTime,
        this.formData.endTime
      );
    },
    subFileds() {
      return this.type === "detail"
        ? []
        : [
            {
              key: "businessStatus",
              filedType: "Radio",
              label: "选择路径",
              span: 24,
              props: {
                disabled: this.type === "detail",
                options: [
                  { value: "UNDO", label: "送审" },
                  { value: "DONE", label: "结束流程" },
                ],
                rules: [
                  { required: true, message: "请选择路径", trigger: "change" },
                ],
              },
            },
            {
              key: "auditorIds",
              filedType: "Cascader",
              label: "添加审批人",
              span: 24,
              hidden: this.formData.businessStatus !== "UNDO",
              props: {
                options: this.personList,
                filterable: true,
                showAllLevels: false,
                disabled: this.type === "detail",
                props: {
                  multiple: true,
                  value: "personId",
                  label: "name",
                  children: "cimContactsVOList",
                },
                rules: [
                  {
                    validator: (rule, value, callback) => {
                      if (this.formData.businessStatus === "UNDO") {
                        if (value.length <= 0) {
                          callback(new Error("请选择审批人"));
                        }
                      }
                      callback();
                    },
                  },
                ],
              },
            },
          ];
    },
  },
  created() {},
  methods: {
    ...mapActions("options", ["getPerson"]),
  },
};
